package cn.ithers.blog.schedule;

import cn.ithers.blog.service.IEsArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;

/**
 * @Author: zhanghuan
 * @date: 2020/11/1 17:14
 * @description:
 */
public class EsImportAllTask {

    @Autowired
    private IEsArticleService esArticleService;

    /**
     * 定义一个按时间执行的定时任务，在每天16:00执行一次
     * 把数据库中的所有文章按时导入es
     */
    @Scheduled(cron = "0 0 16 * * ?")
    public void importArticlesByTime() {
        esArticleService.importAll();
    }
}
